<html>
<head>
<title>Appendix B. Migration to version 1.2</title>
<link rel="stylesheet" type="text/css" href="../media/style.css">
</head>
<body>

<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
  <tr>
    <td class="header_top">HTML_Progress</td>
  </tr>
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
  <tr>
    <td class="header_menu">
  		  [ <a href="../classtrees_HTML_Progress.html" class="menu">class tree: HTML_Progress</a> ]
		  [ <a href="../elementindex_HTML_Progress.html" class="menu">index: HTML_Progress</a> ]
		  [ <a href="../elementindex.html" class="menu">all elements</a> ]
    </td>
  </tr>
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td>
      <table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top">

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="10%" align="left" valign="bottom"><a href=
"../HTML_Progress/tutorial_A_install.pkg.html">Prev</a></td>
<td width="80%" align="center" valign="bottom"></td>
<td width="10%" align="right" valign="bottom"><a href=
"../HTML_Progress/tutorial_C_faq.pkg.html">Next</a></td>
</tr>
</table>
<div><a name=""></a><div class="ref-title-box"><div class="ref-title">Appendix B. Migration to version 1.2</div>
  <div class="ref-purpose">API changes to observe</div></div>

 <span><a name="why-changes"></a><h2 class="title">Why these changes ?</h2><p>HTML_Progress has improved a lot since version 1.1. New features and easy short links comes,
   but also some functionalities was removed.
   With release 1.2 <i><b>HTML_Progress_Model</b></i> class was removed, making
    HTML_Progress package much lighter. But don't worry, the feature still exists:
    see <a href="../HTML_Progress/tutorial_progress.setmodel.pkg.html">HTML_Progress::setModel</a> method.<br /></p></span>

 <span><a name="adjust-code"></a><h2 class="title">How to adjust your code</h2><a name="adjust-code.progress-display"></a><h3 class="title">HTML_Progress::display()</h3><p>When you coded a loop such as:
     <p><div class="listing"><pre><ol><li><span class="src-php">&lt;?php</span></li>
<li><span class="src-inc">require_once </span><span class="src-str">'HTML/Progress.php'</span><span class="src-sym">;</span></li>
<li>&nbsp;</li>
<li><span class="src-var">$bar </span>= <span class="src-key">new </span><span class="src-id"><a href="../HTML_Progress/HTML_Progress.html">HTML_Progress</a></span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li>&nbsp;</li>
<li><span class="src-comm">// ...</span></li>
<li>&nbsp;</li>
<li>do <span class="src-sym">{</span></li>
<li>    <span class="src-var">$bar</span><span class="src-sym">-&gt;</span><span class="src-id">display</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$bar</span><span class="src-sym">-&gt;</span><span class="src-id">getPercentComplete</span><span class="src-sym">(</span><span class="src-sym">) </span>== <span class="src-num">1</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li>        <span class="src-var">$break</span><span class="src-sym">;</span></li>
<li>    <span class="src-sym">} </span></li>
<li>    <span class="src-var">$bar</span><span class="src-sym">-&gt;</span><span class="src-id">incValue</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><span class="src-sym">} </span><span class="src-key">while</span><span class="src-sym">(</span><span class="src-num">1</span><span class="src-sym">)</span></li>
<li><span class="src-php">?&gt;</span></li>
</ol></pre></div></p>
      the sleep action in version 1.1 (an empty for-loop) was included inside 
      <strong>HTML_Progress::display</strong> method.
      Now in version 1.2 a new API comes: <a href="../HTML_Progress/tutorial_progress.sleep.pkg.html">HTML_Progress::sleep</a>
      which used in most case the PHP function <a href="http://www.php.net/manual/en/function.usleep.php">http://www.php.net/manual/en/function.usleep.php</a>,
      rather than an empty for-loop. You should include this new method in your do-while loop,
      as in implementation below:<br />
    <p><div class="listing"><pre><ol><li><span class="src-php">&lt;?php</span></li>
<li><span class="src-inc">require_once </span><span class="src-str">'HTML/Progress.php'</span><span class="src-sym">;</span></li>
<li>&nbsp;</li>
<li><span class="src-var">$bar </span>= <span class="src-key">new </span><span class="src-id"><a href="../HTML_Progress/HTML_Progress.html">HTML_Progress</a></span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li>&nbsp;</li>
<li><span class="src-comm">// ...</span></li>
<li>&nbsp;</li>
<li>do <span class="src-sym">{</span></li>
<li>    <span class="src-var">$bar</span><span class="src-sym">-&gt;</span><span class="src-id">display</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$bar</span><span class="src-sym">-&gt;</span><span class="src-id">getPercentComplete</span><span class="src-sym">(</span><span class="src-sym">) </span>== <span class="src-num">1</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li>        <span class="src-var">$break</span><span class="src-sym">;</span></li>
<li>    <span class="src-sym">} </span></li>
<li>    <span class="src-var">$bar</span><span class="src-sym">-&gt;</span><a href="http://www.php.net/sleep">sleep</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li>    <span class="src-var">$bar</span><span class="src-sym">-&gt;</span><span class="src-id">incValue</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><span class="src-sym">} </span><span class="src-key">while</span><span class="src-sym">(</span><span class="src-num">1</span><span class="src-sym">)</span></li>
<li><span class="src-php">?&gt;</span></li>
</ol></pre></div></p><br />
    <p><table class="note"><tr><td class="note_img"><img src="../media/tip.png"></td><td class="note_text">Of course, you need the HTML_Progress::sleep method only to produce demonstration. In real
      world the user task should at least enough long to delay and smooth progress meter animation.</td></tr></table></p></p><hr />
    
  <a name="adjust-code.progress-run"></a><h3 class="title">HTML_Progress::run()</h3><p>This new API allows to replace a do-while loop as in above example.
    Its also allows to call a user-callback defined by <a href="../HTML_Progress/tutorial_progress.setprogresshandler.pkg.html">HTML_Progress::setProgressHandler</a>
    and manage both progress meter mode (determinate and indeterminate).</p><hr />

  <a name="adjust-code.progress-run"></a><h3 class="title">HTML_Progress::hasErrors(), HTML_Progress::getError()</h3><p>These new API allows to catch HTML_Progress internal errors more easily. 
     See <a href="../HTML_Progress/tutorial_part2-errorhandling.pkg.html">Advanced Error Handling</a> for details.</p>
    <div class="listing"><pre><ol><li><span class="src-php">&lt;?php </span></li>
<li><span class="src-inc">require_once </span><span class="src-str">'HTML/Progress.php'</span><span class="src-sym">;</span></li>
<li>&nbsp;</li>
<li><span class="src-var">$bar </span>= <span class="src-key">new </span><span class="src-id"><a href="../HTML_Progress/HTML_Progress.html">HTML_Progress</a></span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><span class="src-var">$e </span>= <span class="src-var">$bar</span><span class="src-sym">-&gt;</span><span class="src-id">setAnimSpeed</span><span class="src-sym">(</span><span class="src-num">10000</span><span class="src-sym">)</span><span class="src-sym">;   </span><span class="src-comm">// &lt; - - - will generate an API error</span></li>
<li>&nbsp;</li>
<li><span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$bar</span><span class="src-sym">-&gt;</span><span class="src-id">hasErrors</span><span class="src-sym">(</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li>    <span class="src-var">$err </span>= <span class="src-var">$bar</span><span class="src-sym">-&gt;</span><span class="src-id">getError</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li>    echo <span class="src-str">'&lt;h1&gt;Catch HTML_Progress Error&lt;/h1&gt;'</span><span class="src-sym">;</span></li>
<li>    echo <span class="src-str">'&lt;pre&gt;'</span><span class="src-sym">;</span></li>
<li>    <a href="http://www.php.net/print_r">print_r</a><span class="src-sym">(</span><span class="src-var">$err</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li>    echo <span class="src-str">'&lt;/pre&gt;'</span><span class="src-sym">;</span></li>
<li><span class="src-sym">}</span></li>
<li><span class="src-php">?&gt;</span></li>
</ol></pre></div><br /><hr /></span></div>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="33%" align="left" valign="top"><a href="../HTML_Progress/tutorial_A_install.pkg.html">Prev</a></td>
<td width="34%" align="center" valign="top"><a href=
"../HTML_Progress/tutorial_part4-appendixes.pkg.html">Up</a></td>
<td width="33%" align="right" valign="top"><a href=
"../HTML_Progress/tutorial_C_faq.pkg.html">Next</a></td>
</tr>

<tr>
<td width="33%" align="left" valign="top">Appendix A. Installation</td>
<td width="34%" align="center" valign="top">Appendixes</td>
<td width="33%" align="right" valign="top">Appendix C. Frequently Asked Questions</td>
</tr>
</table>
        <div class="credit">
		    <hr />
		    Documentation generated on Sun, 12 Sep 2004 20:23:36 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.3.0RC3</a>
	      </div>
      </td></tr></table>
    </td>
  </tr>
</table>

</body>
</html>